const assert = require('assert');
const BasicLayout = require('../BasicController');

module.exports = class extends BasicLayout {
  constructor(ctx) {
    super(ctx);
    assert(think.isFunction(this.model), 'this.model must be a function');
    this.MODEL = this.ctx.state.ApiInfo.model;
    this.params = {
      model: this.MODEL,
      data: this.post()
    };
  }
  async addannounceAction() {
    const params = this.params;
    params.data.founder = this.ctx.state.UserInfo.num;
    const data = await this.model(params.model).addannounceAction(params);
    return this.success(data);
  }
  async saveAction() {
    const params = this.params;
    const data = await this.model(params.model).saveAction();
    return this.success(data);
  }
  async releaseAction() {
    const params = this.params;
    const data = await this.model(params.model).releaseAction();
    return this.success(data);
  }
};
